/*
               File: ModNroTlf
        Description: Modificar Numero Telefono
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 17:21:38.55
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class pmodnrotlf extends GXProcedure
{
   public pmodnrotlf( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( pmodnrotlf.class ), "" );
   }

   public pmodnrotlf( int remoteHandle ,
                      ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( String aP0 ,
                        long aP1 ,
                        int aP2 ,
                        String aP3 ,
                        int aP4 ,
                        byte aP5 )
   {
      execute_int(aP0, aP1, aP2, aP3, aP4, aP5);
   }

   private void execute_int( String aP0 ,
                             long aP1 ,
                             int aP2 ,
                             String aP3 ,
                             int aP4 ,
                             byte aP5 )
   {
      pmodnrotlf.this.AV9Prscod = aP0;
      pmodnrotlf.this.AV8Cod = aP1;
      pmodnrotlf.this.AV10Prspre = aP2;
      pmodnrotlf.this.AV11Prsnro = aP3;
      pmodnrotlf.this.AV12Prsanx = aP4;
      pmodnrotlf.this.AV13Prsflg = aP5;
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor P00082 */
      pr_default.execute(0, new Object[] {AV9Prscod, new Long(AV8Cod)});
      while ( (pr_default.getStatus(0) != 101) )
      {
         A35PrsCod = P00082_A35PrsCod[0] ;
         A220PrsTlf = P00082_A220PrsTlf[0] ;
         A91PrsPreT = P00082_A91PrsPreT[0] ;
         A92PrsNroT = P00082_A92PrsNroT[0] ;
         A93PrsAnxT = P00082_A93PrsAnxT[0] ;
         A221PrsFlg = P00082_A221PrsFlg[0] ;
         A91PrsPreT = AV10Prspre ;
         A92PrsNroT = AV11Prsnro ;
         A93PrsAnxT = AV12Prsanx ;
         A221PrsFlg = AV13Prsflg ;
         /* Using cursor P00083 */
         pr_default.execute(1, new Object[] {new Integer(A91PrsPreT), A92PrsNroT, new Integer(A93PrsAnxT), new Byte(A221PrsFlg), A35PrsCod, new Byte(A220PrsTlf)});
         /* Check if program is canceled. */
         /* Exiting from a For First loop. */
         if (true) break;
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      Application.commit(context, remoteHandle, "DEFAULT", "pmodnrotlf");
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      P00082_A35PrsCod = new String[] {""} ;
      P00082_A220PrsTlf = new byte[1] ;
      P00082_A91PrsPreT = new int[1] ;
      P00082_A92PrsNroT = new String[] {""} ;
      P00082_A93PrsAnxT = new int[1] ;
      P00082_A221PrsFlg = new byte[1] ;
      A35PrsCod = "" ;
      A220PrsTlf = 0 ;
      A91PrsPreT = 0 ;
      A92PrsNroT = "" ;
      A93PrsAnxT = 0 ;
      A221PrsFlg = 0 ;
      pr_default = new DataStoreProvider(context, remoteHandle, new pmodnrotlf__default(),
         new Object[] {
             new Object[] {
            P00082_A35PrsCod, P00082_A220PrsTlf, P00082_A91PrsPreT, P00082_A92PrsNroT, P00082_A93PrsAnxT, P00082_A221PrsFlg
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private byte AV13Prsflg ;
   private byte A220PrsTlf ;
   private byte A221PrsFlg ;
   private short Gx_err ;
   private int AV10Prspre ;
   private int AV12Prsanx ;
   private int A91PrsPreT ;
   private int A93PrsAnxT ;
   private long AV8Cod ;
   private String AV9Prscod ;
   private String AV11Prsnro ;
   private String A35PrsCod ;
   private String A92PrsNroT ;
   private IDataStoreProvider pr_default ;
   private String[] P00082_A35PrsCod ;
   private byte[] P00082_A220PrsTlf ;
   private int[] P00082_A91PrsPreT ;
   private String[] P00082_A92PrsNroT ;
   private int[] P00082_A93PrsAnxT ;
   private byte[] P00082_A221PrsFlg ;
}

final class pmodnrotlf__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("P00082", "SELECT [PrsCod], [PrsTlfCod], [PrsPreTlf], [PrsNroTlf], [PrsAnxTlf], [PrsFlgMov] FROM [MMPRS20] WITH (UPDLOCK) WHERE [PrsCod] = ? AND [PrsTlfCod] = ? ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,true )
         ,new UpdateCursor("P00083", "UPDATE [MMPRS20] SET [PrsPreTlf]=?, [PrsNroTlf]=?, [PrsAnxTlf]=?, [PrsFlgMov]=?  WHERE [PrsCod] = ? AND [PrsTlfCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((byte[]) buf[1])[0] = rslt.getByte(2) ;
               ((int[]) buf[2])[0] = rslt.getInt(3) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 20) ;
               ((int[]) buf[4])[0] = rslt.getInt(5) ;
               ((byte[]) buf[5])[0] = rslt.getByte(6) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setLong(2, ((Long) parms[1]).longValue());
               break;
            case 1 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               stmt.setString(2, (String)parms[1], 20);
               stmt.setInt(3, ((Integer) parms[2]).intValue());
               stmt.setByte(4, ((Byte) parms[3]).byteValue());
               stmt.setString(5, (String)parms[4], 10);
               stmt.setByte(6, ((Byte) parms[5]).byteValue());
               break;
      }
   }

}

